//
//  UserViewModel.swift
//  XiaoJingMallSwift
//
//  Created by beisheng03 on 2017/7/22.
//  Copyright © 2017年 beisheng. All rights reserved.
//

import UIKit

class UserViewModel: NSObject {

    static let shared = UserViewModel()
    
    var user : UserInfo?
    
    
    var username : String?{
        
        get{
            
            return user?.username
            
        }
        
    }
    
    
    var jp_alias : String?{
        
        get{
            
            return user?.jp_alias
            
        }
        
    }

    
    
    
    var userid : String?{
        
        get{
            
            return user?.userid
            
        }
        
    }

    
    
    
    var key : String?{
        
        get{
            
            return user?.key
            
        }
        
    }
    
    
    
    
    
    override init() {
        super.init()
        //读取用户信息
        let tempUserInfo = NSKeyedUnarchiver.unarchiveObject(withFile: UserInfo.filePath) as? UserInfo
        
        
        user = tempUserInfo
        
    }
    
    
    
    func userIsLogin() -> Bool {
        
        return user != nil
        
    }
    




}
